package com.danco.training.zaneuskaya.controller.book;

import java.io.IOException;





import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.danco.training.zaneuskaya.api.BookService;
import com.danco.training.zaneuskaya.controller.GenericController;
import com.danco.training.zaneuskaya.service.impl.BookServiceImpl;

@SuppressWarnings("serial")
public class BookDeleteController extends GenericController{
	
	private BookService bookService;
	
	public BookDeleteController() {
		super();
		bookService = BookServiceImpl.getBookStorageSeviceImplInstance();

	}
	
	@Override
	protected void doDelete(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
        String id = req.getParameter("id");
		
		bookService.removeEntityById(Integer.parseInt(id));

		getServletContext().getRequestDispatcher("/book/list").forward(
				req, resp);
	}
	
	
}
